<html>
<head><meta charset="utf-8"><title>Floating type associated constants? · t-libs · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/index.html">t-libs</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Floating.20type.20associated.20constants.3F.html">Floating type associated constants?</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="207445917"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Floating%20type%20associated%20constants%3F/near/207445917" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Floating.20type.20associated.20constants.3F.html#207445917">(Aug 19 2020 at 18:43)</a>:</h4>
<p>Recently the integer constants became associated values on the type, <code>i8::MAX</code> and so on. It seems that <code>f32</code> and <code>f64</code> haven't gotten the same improvement.</p>
<p>Is there already a tracker issue for this I should subscribe to?</p>



<a name="207718162"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Floating%20type%20associated%20constants%3F/near/207718162" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lukas Kalbertodt <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Floating.20type.20associated.20constants.3F.html#207718162">(Aug 22 2020 at 10:30)</a>:</h4>
<p>The constants were also moved, see for example: <a href="https://doc.rust-lang.org/std/primitive.f32.html#associatedconstant.MIN">https://doc.rust-lang.org/std/primitive.f32.html#associatedconstant.MIN</a></p>



<a name="207718179"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Floating%20type%20associated%20constants%3F/near/207718179" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lukas Kalbertodt <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Floating.20type.20associated.20constants.3F.html#207718179">(Aug 22 2020 at 10:31)</a>:</h4>
<p>Unlike for the integer types, the <code>f32</code> and <code>f64</code> modules also contain the <code>consts</code> module which is probably not going to move to the types directly.</p>



<a name="207718183"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Floating%20type%20associated%20constants%3F/near/207718183" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lukas Kalbertodt <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Floating.20type.20associated.20constants.3F.html#207718183">(Aug 22 2020 at 10:31)</a>:</h4>
<p>Just for protocol, this is the tracking issue: <a href="https://github.com/rust-lang/rust/issues/68490">https://github.com/rust-lang/rust/issues/68490</a></p>



<a name="207736697"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Floating%20type%20associated%20constants%3F/near/207736697" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Floating.20type.20associated.20constants.3F.html#207736697">(Aug 22 2020 at 18:36)</a>:</h4>
<p>disappointing if they don't ever move over to the type itself.</p>



<a name="207737257"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Floating%20type%20associated%20constants%3F/near/207737257" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lukas Kalbertodt <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Floating.20type.20associated.20constants.3F.html#207737257">(Aug 22 2020 at 18:51)</a>:</h4>
<p>I'm not sure if I understand that message? Are you talking about the constants in the <code>consts</code> modules?</p>



<a name="207737415"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Floating%20type%20associated%20constants%3F/near/207737415" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Floating.20type.20associated.20constants.3F.html#207737415">(Aug 22 2020 at 18:55)</a>:</h4>
<p>if lokathor isn't, i'm willing to make that assertion. <code>std::f32::const::PI</code> is a lot more cumbersome compared to a hypothetical f32::PI</p>



<a name="207744783"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Floating%20type%20associated%20constants%3F/near/207744783" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Floating.20type.20associated.20constants.3F.html#207744783">(Aug 22 2020 at 22:28)</a>:</h4>
<p>yeah, I want <code>f32::PI</code>, and the idea that somehow it's "less appropriate" because it's a number "from math" instead of a number "from the type" is extremely silly and not a good reason.</p>



<a name="207745832"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Floating%20type%20associated%20constants%3F/near/207745832" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Floating.20type.20associated.20constants.3F.html#207745832">(Aug 22 2020 at 23:03)</a>:</h4>
<p>I agree. I <em>do</em> hope that one day we have generic constants in <code>std::consts::PI</code>, but until then, I think <code>f32::PI</code> seems reasonable.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>